﻿
using RsCode;
using RsCode.AspNetCore.Jwt;
using Rswl.Common.Core.User.Aggregate.Entities;
using Rswl.Common.Core.User.Aggregate.ValueObject;
using Rswl.Common.Application.User.Dto;
using RsCms.Application.User.Dto;

namespace Rswl.Common.Application
{
	[ScopedService]
    public interface IUserAppService
    {
        #region 访客用例
        /// <summary>
        /// 自定义帐号注册
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        Task<AccessTokenInfo> PasswordRegisterAsync(PasswordRegiserDto dto);
        /// <summary>
        /// 使用手机号注册
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        Task<AccessTokenInfo> PhoneRegisterAsync(PhoneRegisterDto dto);
        /// <summary>
        /// 使用密码登录
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        Task<AccessTokenInfo> PasswordLoginAsync(PasswordLoginDto dto);

        /// <summary>
        /// 使用微信帐号登录
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        Task<AccessTokenInfo> WechatLoginAsync(WechatLoginDto dto);
        /// <summary>
        /// 找回密码
        /// </summary>
        /// <param name="userName"></param>
        /// <returns></returns>
        Task<string> FindPasswordAsync(PasswordFindDto dto);

        Task<AccessTokenInfo> SmsLoginAsync(SmsLoginDto dto);
        #endregion

        #region 会员用例
        /// <summary>
        /// 更换登录密码
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        Task ChangeLoginPasswordAsync(PasswordChangeDto dto);
        /// <summary>
        /// 获取当前登录用户信息
        /// </summary>
        /// <returns></returns>
        Task<UserInfoDto> GetLoginUserInfoAsync(string appId);
        /// <summary>
        /// 查粉丝
        /// </summary>
        /// <param name="page"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        Task<PageData<UserInfoDto>> PageInviteUserAsync(int page, int pageSize);
        #endregion

        #region 管理员用例
        /// <summary>
        /// 更换用户角色
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        Task ChangeRoleAsync(RoleChangeDto dto);
        /// <summary>
        /// 查看所有用户信息
        /// </summary>
        /// <param name="page"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        Task<PageData<UserInfoDto>> PageUserInfoAsync(int page, int pageSize);

        Task<PageData<UserGradeDto>> PageUserGradeInfoAsync(int page, int pageSize);
        void SaveUserGrade(UserGradeDto grade);
        #endregion

         
		UserRoleEditDto SaveUserRole(UserRoleEditDto dto);
        void DeleteUserRole(long userRoleId);
		Task<UserInfoDto> GetUserAsync(string userId, string appId= "");
        Task<List<UserExtInfo>> GetExtInfoAsync(string userId);

        Task<UserInfoDto> GetOrCreateUserAsync(UserAuthInfoDto dto);
        Task<AccessTokenInfo> PhoneLogin(PhoneLoginDto dto);

        Task<AccessTokenInfo> UserLogin(UserLoginDto dto);

        
        Task<UserInfoDto> ChangeUserInfoAsync(string userId, ChangeUserInfoDto dto);
        Task<List<UserInfoDto>> GetAdminListAsync();

        /// <summary>
        /// 管理员登录
        /// </summary>
        /// <param name="openId"></param>
        /// <returns></returns>
        Task<AccessTokenInfo> AdminLoginAsync(PasswordLoginDto dto);

        Task<PageData<UserInfoDto>> GetPageUserAsync(int page);

        Task SetAdminAsync(string userId);

        Task CancelAdminAsync(string userId);

        Task<List<ShippingAddressDto>> GetShippingAddressesAsync(string userId);
        Task<long> SaveShippingAddressAsync(string userId, ShippingAddressEditDto dto);
        Task RemoveShippingAddressAsync(string userId, long addressId);

        Task BindInviteCodeAsync(string userId, string inviteCode);
        Task<ShareInfoDto> GetShareInfoAsync(string userId);

       
        Task ChangeGradeAsync(string userId, UserGrade grade,int days);
        /// <summary>
        /// 计算推广VIP奖励金币的额度
        /// </summary>
        /// <param name="Grade">推广者</param>
        /// <param name="invoteGrade">被推广者</param>
        /// <returns></returns>
        int InvoteVipAwardAmount(UserGrade Grade, UserGrade invoteGrade);

        /// <summary>
        /// 积分价格
        /// </summary>
        /// <param name="Grade"></param>
        /// <param name="integralAmount"></param>
        /// <returns></returns>
        decimal IntegralPrice(UserGrade Grade, long integralAmount);

        /// <summary>
        /// 获取积分价格信息
        /// </summary>
        /// <param name="grade"></param> 
        /// <returns></returns>
        object GetIntegralPriceInfo(int grade);

        Task<PageData<UserInfoDto>> PageFansAsync(int page, int pageSize, string userId);

        Task AdminCreateAccountAsync(AccountCreateDto dto);
        Task ChangeAccountStatusAsync(AccountStatusEditDto dto);
	}
}
